<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
</head>
<body>


欢迎来到摩件世界<br/>

请先选择一种登录方式使用我们的系统...<br/>

<label>手机号码</label><input type="text" alt="请输入内容" name="mobile" id="mobile"/><br/>
<label>验证码</label><input type="text" alt="请填写验证码" name="code"/><br/>
<label id="msg" style="display: none"></label>
<input type="button" value="获取验证码" onclick="sendCode()"/><br/>
<input type="button" value="快捷登录" onclick="mobileLogin()" id=""/><br/>
<input type="button" value="稍后登录,我先看看" onclick="waitLogin()"/><br/>
</body>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="utils.js"></script>
<script>
    /**
     * 发送验证码
     */
    function sendCode() {
        let mobile = document.getElementById("mobile").value;
        if (!mobile) {
            alert("手机号码不能为空!");
            return;
        }
        axios.get("http://192.168.100.122:8080/api/sms/sendCode").then(res => {
            alert("发送成功!");
        }).catch(error => {
            alert("发送失败!请稍后在试!");
        })
    }

    /**
     * 手机号码登录
     */
    function mobileLogin() {
        let mobile = document.getElementById("mobile").value;
        let code = document.getElementById("mobile").value;
        axios.get("http://192.168.100.122:8080/api/sms/sendCode").then(res => {
            alert("发送成功!");
        }).catch(error => {
            alert("发送失败!请稍后在试!");
        })

    }

    /**
     * 手机号码是否已经注册
     */
    function mobileIsExits(mobile) {
        axios.get("http://192.168.100.122:8080/api/user/mobileIsExits=" + mobile).then(res => {
            if (res.data.code == 200) {
                return true;
            } else {
                return false;
            }
        }).catch(error => {
            alert("请求错误!请联系服务器人员进行处理!");
            return true;
        })
    }

    /**
     * 写入推荐人到缓存.
     */
    window.onload = function () {
        let params = getUrlParams();
        window.localStorage["ref"] = params["ref"];
    }


</script>
</html>